package me.lensfrex.trailblazer.api.v1.dao;

import me.lensfrex.trailblazer.api.v1.dao.sql.UserDaoInterface;
import me.lensfrex.trailblazer.api.v1.pojos.UserInformation;
import me.lensfrex.trailblazer.api.v1.utils.database.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

public class UserDao {
    public static UserInformation getUser(String userName) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession(true);

        UserDaoInterface mapper = sqlSession.getMapper(UserDaoInterface.class);

        return mapper.getBasicInfoByUserName(userName);
    }

    public static boolean isUserAlreadyExist(String userName) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession(true);

        UserDaoInterface mapper = sqlSession.getMapper(UserDaoInterface.class);

        return mapper.isUserNameAlreadyExists(userName);
    }

    public static int addUser(String UUID, String userName, String password) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession(true);

        UserDaoInterface mapper = sqlSession.getMapper(UserDaoInterface.class);

        return mapper.addRegisterInfoIntoDb(UUID, userName, password);
    }
}
